package com.xbongbong.pro.enums;

import com.xbongbong.i18n.util.I18nMessageUtil;
import lombok.Getter;

/**
 * @description: 动态负责人级别
 * @Author: hongxiao
 * @date: 2019-10-24 08:57
 * @since v4.5.0
 */
@Getter
public enum DynamicManagerLevelEnum {
    /**
     * 枚举 one two three four five
     * six seven eight nine ten
     * eleven twelve thirteen fourteen fifteen
     * sixteen seventeen eighteen nineteen twenty
     */
    ZERO_LEVEL("", 0),
    ONE_LEVEL("enum.dynamicManagerLevel.name.one_level",1),


    TWO_LEVEL("enum.dynamicManagerLevel.name.two_level",2),


    THREE_LEVEL("enum.dynamicManagerLevel.name.three_level",3),


    FOUR_LEVEL("enum.dynamicManagerLevel.name.four_level",4),


    FIVE_LEVEL("enum.dynamicManagerLevel.name.five_level",5),


    SIX_LEVEL("enum.dynamicManagerLevel.name.six_level",6),


    SEVEN_LEVEL("enum.dynamicManagerLevel.name.seven_level",7),


    EIGHT_LEVEL("enum.dynamicManagerLevel.name.eight_level",8),


    NINE_LEVEL("enum.dynamicManagerLevel.name.nine_level",9),


    TEN_LEVEL("enum.dynamicManagerLevel.name.ten_level",10),


    ELEVEN_LEVEL("enum.dynamicManagerLevel.name.eleven_level",11),


    TWELVE_LEVEL("enum.dynamicManagerLevel.name.twelve_level",12),


    THIRTEEN_LEVEL("enum.dynamicManagerLevel.name.thirteen_level",13),


    FOURTEEN_LEVEL("enum.dynamicManagerLevel.name.fourteen_level",14),


    FIFTEEN_LEVEL("enum.dynamicManagerLevel.name.fifteen_level",15),


    SIXTEEN_LEVEL("enum.dynamicManagerLevel.name.sixteen_level",16),


    SEVENTEEN_LEVEL("enum.dynamicManagerLevel.name.seventeen_level",17),


    EIGHTEEN_LEVEL("enum.dynamicManagerLevel.name.eighteen_level",18),


    NINETEEN_LEVEL("enum.dynamicManagerLevel.name.nineteen_level",19),


    TWENTY_LEVEL("enum.dynamicManagerLevel.name.twenty_level",20),


    TOP_LEVEL("enum.dynamicManagerLevel.name.top_level",-1),
    ;

    /**
     * 名称
     */
    private String name;
    /**
     * 级别
     */
    private int level;

    DynamicManagerLevelEnum(String name, Integer level) {
        this.name = name;
        this.level = level;
    }

    public static DynamicManagerLevelEnum getByLevel(Integer level) {
        if(level == null) {
            return ZERO_LEVEL;
        }
        for (DynamicManagerLevelEnum cacheCode : values()) {
            if (level.equals(cacheCode.getLevel())) {
                return cacheCode;
            }
        }
        return ZERO_LEVEL;
    }

    public static String getName(int level) {
        for(DynamicManagerLevelEnum managerEnum: values()){
            if(managerEnum.getLevel() == level) {
                return managerEnum.getName();
            }
        }
        return "";
    }

    public String getName() {
        return I18nMessageUtil.getMessage(name);
    }
}
